#include <iostream>

/* 请求 涨薪 */

struct request
{
    int money;
};
/* 管理者抽象类 */
class Manager
{
public:
    Manager(const std::string & name, Manager *m)   //传入的形参为当前管理者名称、上级管理者名称
    {
        this->name = name;
        this->m = m;
    }
    virtual void HandleRequest(request * t) = 0;
protected:
    std::string name;
    Manager *m;
};
/* 普通经理 */
class CommonManager : public Manager 
{
public:
    using Manager::Manager;         //继承构造
    void HandleRequest(request * t)
    {
        if(t->money <= 1000)
        {
            std::cout<<name<<"批准涨薪"<<t->money<<"的请求\n";
        }
        else
        {
            m->HandleRequest(t);    //超出批准范畴，往上级回调
        }
    }
};
/* 总监 */
class Major : public Manager   
{
public:
    using Manager::Manager;
    void HandleRequest(request * t)
    {
        if(t->money <= 2000)
        {
            std::cout<<name<<"批准涨薪"<<t->money<<"的请求\n";
        }
        else
        {
            m->HandleRequest(t);  
        }
    }
};
/* 总经理 */
class GeneralManager : public Manager    
{
public:
    using Manager::Manager;
    void HandleRequest(request * t)
    {
        std::cout<<name<<"批准涨薪"<<t->money<<"的请求\n";
    }
};

int main()
{
    Manager * g = new GeneralManager("张总", nullptr);
    Manager * j = new Major("李总监", g);
    Manager * cm = new CommonManager("王经理", j);

    request * r = new request;

    r->money = 1500;

    cm->HandleRequest(r);

    return 0; 
}